<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单信息列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            订单编号：
                            <input type="text" name="orderId"/>
                        </li>
                        <li>
                            订单状态：
                            <select name="orderStatus"
                                    th:with="type=${@dict.getType('order_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            所属客户代码：
                            <input type="text" name="referCustomerId"/>
                        </li>
                        <li>
                            订单类型：
                            <select name="orderType"
                                    th:with="type=${@dict.getType('order_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            寄件人名称：
                            <input type="text" name="fCustName"/>
                        </li>
                        <li>
                            寄件人联系方式：
                            <input type="text" name="fCustTele"/>
                        </li>
                        <li>
                            收货人名称：
                            <input type="text" name="sCustName"/>
                        </li>
                        <li>
                            收货人联系方式：
                            <input type="text" name="sCustTele"/>
                        </li>


                        <li class="select-time">
                            预约起始时间：
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginSubscribeStartTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endSubscribeStartTime]"/>
                        </li>
                        <li class="select-time">
                            预约结束时间：
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginSubscribeEndTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endSubscribeEndTime]"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="bus:baseOrder:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="bus:baseOrder:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-primary single disabled" onclick="submitOrder()">
                <i class="fa fa-send"></i> 发货
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="bus:baseOrder:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="bus:baseOrder:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('bus:baseOrder:edit')}]];
    var removeFlag = [[${@permission.hasPermi('bus:baseOrder:remove')}]];

    var orderStatusDatas = [[${@dict.getType('order_status')}]];


    var goodsTypeDatas = [[${@dict.getType('goods_type')}]];

    var orderType= [[${@dict.getType('order_type')}]];

    var prefix = ctx + "bus/baseOrder";
        function submitOrder() {
            var row = $('#bootstrap-table').bootstrapTable('getSelections')[0]
            if (row.orderStatus!='20'){
                $.modal.alertError('订单未支付,不能发货!');
                return
            }
            if (row.orderType!='20'){
                $.modal.alertError('非网点寄件,不能发货!');
                return
            }
            $.modal.open("发货",prefix+"/submit/"+row.id );

        }

    var options = {
        url: prefix + "/list",
        createUrl: prefix + "/add",
        updateUrl: prefix + "/edit/{id}",
        removeUrl: prefix + "/remove",
        exportUrl: prefix + "/export",
        modalName: "订单信息",
        columns: [{
            checkbox: true
        },
            {
                field: 'id',
                title: 'ID',
                visible: false
            },
            {
                field: 'orderId',
                title: '订单编号',
                align:"center"
            },
            {
                field: 'transOrderId',
                title: '运单号',
                align:"center"
            },
            {
                field: 'orderStatus',
                title: '订单状态',
                align:"center",
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(orderStatusDatas, value);
                }
            },
            {
                field: 'referCustomerId',
                title: '所属客户代码',
                align:"center"
            },
            {
                field: 'orderType',
                title: '订单类型',
                align:"center",
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(orderType, value);
                }
            },
            {
                field: 'fCustName',
                title: '寄件人名称',
                align:"center"

            },
            {
                field: 'fCustTele',
                title: '寄件人联系方式',
                align:"center"

            },
            {
                field: 'fCustAddr',
                title: '发货地址',
                width:150,
                align:"center"

            },
            {
                field: 'sCustName',
                title: '收货人名称',
                align:"center"

            },
            {
                field: 'sCustTele',
                title: '收货人联系方式',
                align:"center"

            },
            {
                field: 'sCustAddr',
                title: '收货地址',
                align:"center"

            },
            {
                field: 'transName',
                title: '物流商名称',
                align:"center"

            },
            {
                field: 'unitPrice',
                title: '单价',
                align:"center"

            },
            {
                field: 'goodsType',
                title: '货物类型',
                align:"center",
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(goodsTypeDatas, value);
                }
            },
            {
                field: 'goodsWeight',
                title: '货物重量',
                align:"center"

            },
            {
                field: 'subscribeStartTime',
                title: '预约起始时间',
                align:"center"

            },
            {
                field: 'subscribeEndTime',
                title: '预约结束时间',
                align:"center"
            },
            {
                field: 'totalPrice',
                title: '金额',
                align:"center"

            },
            {
                field: 'networkName',
                title: '网点名称',
                align:"center"
            }]
    };
    $(function () {

        $.table.init(options);
    });
</script>
</body>
</html>